package cn.wolfcode.service.impl;

import cn.wolfcode.domain.Emp;
import cn.wolfcode.domain.ResultPage;
import cn.wolfcode.mapper.EmpMapper;
import cn.wolfcode.service.EmpService;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class EmpServiceImpl implements EmpService {
    @Autowired
    private EmpMapper empMapper;
    @Override
    public ResultPage getAll(Integer page, Integer pageSize, Integer gender, String name, Date begin, Date end) {
        PageHelper.startPage(page,pageSize);
        List<Emp> emps=empMapper.selectCorrespond(gender,name,begin,end);
        Page<Emp> p=(Page<Emp>) emps;
       return  new ResultPage(p.getTotal(),p.getResult());
    }

    @Override
    public void delete(Long[] ids) {
        empMapper.batchDelete(ids);
    }

    @Override
    public void add(Emp emp) {
        empMapper.add(emp);
    }

    @Override
    public void update(Emp emp) {

        empMapper.update(emp);
    }

    @Override
    public Emp getOneById(Long id) {
        return empMapper.getOneById(id);
    }

    @Override
    public Emp login(Emp loginemp) {
        return empMapper.login(loginemp);
    }
}
